import pandas as pd
import numpy as np

def zscore(df, value=None, window=1000, column='close'):
    rolling_mean = df[column].rolling(window=window).mean().iloc[-1]
    rolling_std = df[column].rolling(window=window).std().iloc[-1]
    if not value:
        value = df[column].iloc[-1]
    z_score = (value - rolling_mean) / rolling_std
    # print(f"{value}, {rolling_mean}, {rolling_std}, {z_score}")
    return z_score

def zscore_get_percentage(df, zscore_value, window=None, column='close'):
    if not window:
        window = len(df)
    rolling_mean = df[column].rolling(window=window).mean().iloc[-1]
    rolling_std = df[column].rolling(window=window).std().iloc[-1]
    value = zscore_value * rolling_std + rolling_mean
    print(f"{value}, {rolling_mean}, {rolling_std}")
    return value
    